package com.sjd.common.utils.sql;

import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper;
import tk.mybatis.mapper.provider.base.BaseInsertProvider;

/**
  *@CalssName BaseMapper
  *@Description //TODO
  *@Authot genglong
  *@Date 2022/1/11 10:40
  *@Version 1.0
  **/
public interface BaseMapper<T> extends Mapper<T>, MySqlMapper<T> {
    /*
     * Mapper：基本的增、删、改、查方法
     * MySqlMapper：针对MySQL的额外补充接口，支持批量插入
     *
     * 此接口不能被扫描到
     */

    /**
     * 重写默认插入方法，支持返回主键
     *
     * @param record
     * @return
     */
    @Override
    @Options(useGeneratedKeys = true)
    @InsertProvider(type = BaseInsertProvider.class, method = "dynamicSQL")
    int insert(T record);

    /**
     * 重写默认插入方法，支持返回主键
     *
     * @param record
     * @return
     */
    @Override
    @Options(useGeneratedKeys = true)
    @InsertProvider(type = BaseInsertProvider.class, method = "dynamicSQL")
    int insertSelective(T record);
}
